package br.com.yurikimo.ykkit;

import android.widget.EditText;
import android.widget.RelativeLayout;

public class YKEditText extends EditText implements YKBaseComponent
{
	private YKLayoutManager layoutManager;
	
	public YKEditText(String label){
		super(YKDirector.getActivity());
		
		this.setText(label);
		
		init();
	}
	
	public YKEditText(String label,float x, float y, float width, float height){
		super(YKDirector.getActivity());
		
		setText(label);
				
		init();

		setBounds(x, y, width, height);		
	}
	
	private void init(){
		layoutManager = new YKLayoutManager(this);
		
		if (YKDirector.getDefaultFontName() != null){
			setTypeface(YKFontManager.loadFont(YKDirector.getDefaultFontName(), YKFontManager.FONT_TTF));
		}
	}
	
	public void setBounds(float x, float y, float width, float height){
		layoutManager.setBounds(x, y, width, height);
	}
	
	public void addToLayout(RelativeLayout relativeLayout){
		layoutManager.addToLayout(relativeLayout);
	}
	
	public float getObjectWidth(){
		return layoutManager.getObjectWidth();
	}
	
	public float getObjectHeight(){
		return layoutManager.getObjectHeight();
	}
	
	public float getObjectX(){
		return layoutManager.getObjectX();
	}
	
	public float getObjectY(){
		return layoutManager.getObjectY();
	}
	
	public void refreshLayout(){
		layoutManager.refreshLayout();
	}
	
	public void setPosition(float x, float y){
		layoutManager.setPosition(x, y);
	}
		
	public void removeFromSuperView(){
		layoutManager.removeFromSuperView();
	}

	public RelativeLayout getLayoutView()
	{
		return layoutManager.getLayoutView(getContext());
	}

	public YKContainer getObjectParent()
	{
		return layoutManager.getObjectParent();
	}

	public void setObjectParent(YKContainer parent)
	{
		layoutManager.setObjectParent(parent);
	}
}
